package com.fz.controller;

import com.fz.entity.TPermission;
import com.fz.service.TPermissionService;
import com.fz.vo.ResultVo;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 权限菜单表 前端控制器
 * </p>
 *
 * @author fz
 * @since 2024-08-17
 */
@RestController
@RequestMapping("/tPermission")
public class TPermissionController {
    @Resource
    TPermissionService tPermissionService;
    @GetMapping("/list")
    ResultVo<List<TPermission>> list() {
        return ResultVo.success(tPermissionService.getList());
    }
    @PostMapping("/add")
    ResultVo<Boolean> add(String name,String description,String path,Integer level,Integer parentId,Integer type) {
        return ResultVo.success(tPermissionService.add(name,description,path,level,parentId,type),"添加权限成功");
    }
    @GetMapping("/getById")
    ResultVo<TPermission> getById(Integer id) {
        return ResultVo.success(tPermissionService.getById(id));
    }
    @PostMapping("/update")
    ResultVo<Boolean> update(Long id,String name,String description,String path,Integer level,Integer parentId,Integer type){
        return  ResultVo.success(tPermissionService.update(id,name,description,path,level,parentId,type),"修改权限成功");
    }
    @PostMapping("/del")
    ResultVo<Boolean> del(Long id){
        return  ResultVo.success(tPermissionService.del(id),"删除权限成功");
    }
}
